home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Source Code / QuArK / source / 3d code review.txt next >
Text File  |  2004-01-05  |  4KB  |  123 lines

  1.  
  2. #$Header: /cvsroot/quark/source/3d\040code\040review.txt,v 1.3 2003/09/06 02:22:11 tiglari Exp $
  3.  
  4.  
  5. AddTo3DScene:
  6.  
  7. AddTo3DScene is the method of map objects whereby the map structure
  8. builds the 3d scene.  The real work is done by methods such as
  9. TFace.AddTo3DScene in prog/QkMapPoly.pas [tig: what is the correct name for
  10. a subclass's implementation of a virtual method?]; we see that
  11. the workhorse line is:
  12.  
  13.         CurrentMapView.Scene.AddPolyFace(P);
  14.  
  15. CurrentMapView is a global variable of type TPyMapView defined by
  16. this line of python/PyMapView.pas:
  17.  
  18.  CurrentMapView : TPyMapView = TPyMapView(-1);
  19.  
  20. A TPyMapView is a subclass of TScrollBox, I presume the -1 is setting
  21. its owner to nothing [tig: check this].  For some reason, Scene is a property
  22. whose read method is FScene, whose value is a TSceneObject.
  23.  
  24. TSceneObject:
  25.  
  26. TSceneObject defined in 3dfx/EdSceneObject.pas, with subclasses:
  27.  
  28.   3dfx\Ed3DFX.pas(123): T3DFXSceneObject = class(TSceneObject)
  29.   3dfx\EdOpenGL.pas(107): TGLSceneBase = class(TSceneObject)
  30.   3dfx\EdDirect3D.pas(60): TDirect3DSceneObject = class(TSceneObject)
  31.  
  32. The first is the class for the software and 3dfx 3d textured
  33. views, the second of the OGL one, and the last is the start of
  34. an unfinished projet to produce a 3dfx view; the appropriate
  35. constructors are called by python/PyMapView:TPyMapView.NeedScene.
  36.  
  37. EdSceneObject.pas:  Seems to be divided into two sections, one concerned
  38. with TSceneObject, the other with TTexture Manager.  The interesting
  39. non-virtual method is BuildScene, which is very big - Armin seems
  40. to often have gone for extremely long functions, which are supposed to
  41. be bad style, so perhaps we could think about breaking this  one
  42. up into intelligible bits?
  43.  
  44. An important type in 3d scene building is PSurface, defined in
  45. prog/QkMapPoly.pas, which defines a visible polyhedron face.  It
  46. is a pointer to a TSurface, defined as follows:
  47.  
  48. TSurface = record
  49.              Source: TTreeMap;
  50.              F: TFace;
  51.              NextF: PSurface;   { linked list of PSurfaces for a given face }
  52.              prvVertexCount: Integer;
  53.              prvVertexTable: TFVertexTable;
  54.             end;
  55.  
  56. Each face has a linked list of PSurfaces because of face-sharing. F is
  57. used to get info about the texture-name, etc., Source isn't used by
  58. this module.  The PSurfaces are rebuilt by code in QkMapPoly.pas.
  59.  
  60. The AddSurfaceRef sub-procedure of BuildScene adds a surface to a master-list
  61. of surfaces, TSceneObject.FListSurfaces, accesible also as read-property
  62. ListSurfaces. Need to  understand BuildScene to see what this does.
  63.  
  64. Questions about TSceneObject:
  65.  
  66.   how does BuildScene work?
  67.   what is SetColor do for?
  68.   what is the purpose of ChangeQuality?
  69.  
  70. BuildScene:
  71.  
  72.   If a 3d window is open, gets called every time anything happens to the
  73.    views.  This seems excessive, for example for a selection event very little
  74.    gets changed.
  75.  
  76.   1.  some initializations:
  77.          Held over from previous BuildScene:
  78.            TextureManager
  79.          Reinitialized:
  80.            TexNames list
  81.            FlistSurfaces - done via linked list freeing, maybe a slowdown factor?
  82.            nVertexList and nVertexList2
  83.  
  84.   2.  scan the map objects and build the TexNames list, which gives
  85.         information about surfaces indexed by the TexNames, and
  86.         also add this information to the FlistSurfaces list.
  87.         
  88.        Problem: the info specifyies how much info is needed to store
  89.        the vertexes of the faces using the texture, but no info about
  90.        those vertexes seems to be recorded.
  91.        
  92.  
  93.   3.  rebuild the old textures, note how many new ones needed.
  94.         Q: what does building do?
  95.   
  96.   4.  free old textures no longer needed
  97.   
  98.   5.  load and build new textures
  99.   
  100.   6.  build a lot of stuff
  101.   
  102.   7.  for each face, load a lot of stuff into the appropriate
  103.         surf3d element [some of it looks like texture coordinates]
  104.   
  105.   8.  ditto for models, sprites and beziers
  106.         lots of rather repetitive-looking code.
  107.         
  108.   9.  and a bit of final cleanup.
  109.   
  110. More understanding of what goes on it steps 7-8 is needed here.
  111.  
  112.   
  113. #$Log: 3d\040code\040review.txt,v $
  114. #Revision 1.3  2003/09/06 02:22:11  tiglari
  115. #BuildScene - first go at overview
  116. #
  117. #Revision 1.2  2003/09/02 23:35:13  tiglari
  118. #More on EdSceneObject.pas, also some questions added
  119. #
  120. #Revision 1.1  2003/09/02 00:01:43  tiglari
  121. #started by tiglari, some points for more work bracketted as [tig: ...]
  122. #
  123.